How to Export data from A DBF file to Access 2003 table programatically (1 Viewer)

priyankad

New member
Local time
Today, 05:30
Joined
Sep 26, 2008
Messages
2
Hi all,

I want to export data from a DBF file to an Access table programatically.
I can export from a tab delimited text file but I don't have any idea how to do this from a DBF file.

Following is the code to export from a tab delimited text file
--------------------------------------------------------------
'strPath = the path of the text file to be exported into the Access table

Dim DB As DAO.Database, rs As DAO.Recordset
Dim str1 As String, str2 As Variant
Dim i As Integer
Set DB = CurrentDb
Set rs = DB.OpenRecordset("TableName")
Dim intFile As Integer
intFile = FreeFile
Open strPath For Input As intFile
Do While Not EOF(1)
Line Input #intFile, str1

If str1 <> "col1" & vbTab & "col2" & vbTab & "col3" & vbTab & "col4" & vbTab & "col5" & vbTab & "col6" & vbTab & "col7" & vbTab & "col8" & vbTab & "col9" & vbTab & "col10" & vbTab & "col11" & vbTab & "col12" & vbTab & "col13" & vbTab & "col14" & vbTab & "col15" & vbTab & "col16" & vbTab & "col17" Then
str2 = Split(str1, vbTab)
rs.AddNew
For i = 0 To UBound(str2)
On Error Resume Next
rs(i) = str2(i)
Next
rs.Update
End If
Loop
Close #intFile
rs.Close
--------------------------------------------------------------

Can anybody help me solving this issue.

Thanks
Priyanka
 

KenHigg

Registered User
Local time
Today, 08:30
Joined
Jun 9, 2004
Messages
13,327
I would place the dbf in a specific folder and attach to it via odbc. Then when you have a new version of the dbf replace the old one with the new one. Then when you open the Access db your linked table will contain the rows in the new dbf file.
 

priyankad

New member
Local time
Today, 05:30
Joined
Sep 26, 2008
Messages
2
Thanks Ken.
I am new to Access world, so could not understand your point.
Could you please explain it in detail step wise.
Thank you.
 

Users who are viewing this thread

Top Bottom